# Maintainer: Balló György <ballogyor+arch at gmail dot com>

pkgname=ocrfeeder
pkgver=0.8.5
pkgrel=2
pkgdesc='GTK document layout analysis and optical character recognition application'
arch=('any')
url='https://wiki.gnome.org/Apps/OCRFeeder'
license=('GPL3')
depends=('ghostscript' 'goocanvas' 'gtk3' 'gtkspell3' 'iso-codes' 'python-gobject' 'python-odfpy'
         'python-pillow' 'python-pyenchant' 'python-reportlab' 'python-sane' 'unpaper')
makedepends=('git' 'gnome-common')
optdepends=('cuneiform: character recognition'
            'gocr: character recognition'
            'ocrad: character recognition'
            'tesseract: character recognition')
_commit=edd666ac6f04720f3a8ec1bd9f082308d282491d
source=("git+https://gitlab.gnome.org/GNOME/ocrfeeder.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^release_//;s/_/./g;s/-/+/g'
}

prepare() {
  cd $pkgname

  # Remove the usage of deprecated 'xml.etree.ElementTree.Element.getchildren' (FS#69470)
  git cherry-pick -n c0c460893961d5589f300645b32b5584a6c3f463

  # Port to GooCanvas 3.0
  git cherry-pick -n 2a580ed065764c96da34634fc9186f81234f8ca5

  # Fix gocr parameters
  git cherry-pick -n 2e1a634f35c03acffdbbbdd50c0d979578389057

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure --prefix=/usr
  make
}

check() {
  make -C $pkgname check
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -Dm644 resources/icons/org.gnome.OCRFeeder.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/org.gnome.OCRFeeder.svg"
}
